from ronglian_sms_sdk import SmsSDK
import json

def sendMsg(mobile,code):
    accid = "8aaf070881ad8ad401821a3604181b51"
    acctoken = "741d8a15873b4097ac5c1b428c8e2a5e"
    appid = "8aaf070881ad8ad401821a3604f51b58"
    sdk = SmsSDK(accid,acctoken,appid)
    tid = '1'
    datas = (code,'5')
    resp = sdk.sendMessage(tid,mobile,datas)
    return resp

import hashlib

from tools.pay import AliPay


def md5(pwd):
    password = hashlib.md5(pwd.encode())
    return password.hexdigest()

#初 始化阿里支付对象
def get_ali_object():
    # 沙箱环境地址：https://openhome.alipay.com/platform/appDaily.htm?tab=info
    app_id = "2021000122602111"  #  APPID （沙箱应用）

    # 支付完成后，支付偷偷向这里地址发送一个post请求，识别公网IP,如果是 192.168.20.13局域网IP ,支付宝找不到，def page2() 接收不到这个请求
    notify_url = "http://localhost:8000/user/callback/"

    # 支付完成后，跳转的地址。
    return_url = "http://localhost:8000/user/callback/"

    merchant_private_key_path = "E:\积云教育\人工智能\p9\总\education\keys\private_key.txt" # 应用私钥
    alipay_public_key_path = "E:\积云教育\人工智能\p9\总\education\keys\public_key.txt"  # 支付宝公钥

    alipay = AliPay(
        appid=app_id,
        app_notify_url=notify_url,
        return_url=return_url,
        app_private_key_path=merchant_private_key_path,
        alipay_public_key_path=alipay_public_key_path,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥
        debug=True,  # 默认False,
    )
    return alipay

